package net.kindleit.mpd.jukebox;

import java.net.UnknownHostException;

import org.apache.wicket.protocol.http.WebApplication;
import org.bff.javampd.MPD;
import org.bff.javampd.exception.MPDConnectionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Application object for your web application. If you want to run this application without deploying, run the Start class.
 *
 * @see net.kindleit.mpd.jukebox.Start#main(String[])
 */
public class WicketApplication extends WebApplication
{

  private static final Logger LOG = LoggerFactory.getLogger(WicketApplication.class);


  private MPD mpdInstance;

  @Override
  protected void init() {
    try {
      mpdInstance = new MPD("localhost");
    } catch (final UnknownHostException e) {
      LOG.error("Unknown MPD Host", e);
    } catch (final MPDConnectionException e) {
      LOG.error("MPD Connection Error", e);
    }
    super.init();
  }

  /**
   * @see org.apache.wicket.Application#getHomePage()
   */
  @Override
  public Class<HomePage> getHomePage()
  {
    return HomePage.class;
  }

  public MPD getMPD() {
    return mpdInstance;
  }

}
